#!/usr/bin/python
# -*- coding: utf-8 -*-
#Create ui_* files to load into python automatically
#to run: python compileUiFiles.py

from PyQt4 import uic
import os

def comp(filename):
	newName = filename[0:filename.find('/')+1]+'ui_'+filename[filename.find('/')+1:-3]+'.py'
	newFile = file(newName, 'w')
	uic.compileUi(filename, newFile)


if __name__=="__main__":
	print "Compiling all ui files"
	dirs = [i for i in os.listdir('.') if os.path.isdir(i)]
	for d in dirs:
		files = [i for i in os.listdir(d) if i.endswith('.ui')]
		for i in files:
			comp(d+'/'+i)